# Author:sp
# CreaTime: $(DATE)
# FileName: $(NAME)
# Description: simple introdution of the code
#封装
class Student:
    def __init__(self,name,age):
        self.name=name
        self.__age=age                   #不希望外部调用age,实例属性不希望被外部调用时需要加__
    def fun(self):
        print(self.name,'今年有',self.__age)

stu=Student('jack',20)
print(stu.fun())
print(stu.name)
#print(stu.__age)         AttributeError: 'Student' object has no attribute '__age'
#print(dir(stu))
print(stu._Student__age)                 #在类的外部可以通过  _Student__age调用



